package com.example.mybroadcast;

import androidx.appcompat.app.AppCompatActivity;

import android.content.IntentFilter;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
    MyBroadcastReceiver receiver;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        receiver=new MyBroadcastReceiver();
        String action="android.provider.Telephony.SMS_RECEIVED";
        IntentFilter intentFilter=new IntentFilter();
        intentFilter.addAction(action);
        this.registerReceiver(receiver,intentFilter);
    }
}
